libkovan
1
The kovan standard library
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
button.hpp
Go to the documentation of this file.
1
/**************************************************************************
2
* Copyright 2012 KISS Institute for Practical Robotics *
3
* *
4
* This file is part of libkovan. *
5
* *
6
* libkovan is free software: you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation, either version 2 of the License, or *
9
* (at your option) any later version. *
10
* *
11
* libkovan is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
15
* *
16
* You should have received a copy of the GNU General Public License *
17
* along with libkovan. Check the LICENSE file in the project root. *
18
* If not, see <http://www.gnu.org/licenses/>. *
19
**************************************************************************/
20
29
#ifndef _BUTTON_HPP_
30
#define _BUTTON_HPP_
31
32
#include "
sensor.hpp
"
33
#include "
button_ids.hpp
"
34
#include "
export.h
"
35
36
43
class
EXPORT_SYM
AbstractButton
:
public
Sensor
<bool>
44
{
45
public
:
46
virtual
~
AbstractButton
();
47
virtual
void
setPressed(
bool
pressed) = 0;
48
54
inline
bool
isPressed
()
const
{
return
value
(); };
55
60
inline
bool
isNotPressed
()
const
{
return
!isPressed(); }
61
70
inline
bool
isClicked
()
const
71
{
72
const
bool
ret = isPressed();
73
waitUntilReleased();
74
return
ret;
75
}
76
77
78
83
virtual
void
waitUntilReleased()
const
;
84
89
virtual
void
waitUntilPressed()
const
;
90
95
virtual
void
waitUntilClicked()
const
;
96
};
97
104
class
EXPORT_SYM
AbstractTextButton
:
public
AbstractButton
105
{
106
public
:
107
virtual
~
AbstractTextButton
();
108
114
virtual
void
setText(
const
char
*text) = 0;
115
121
virtual
const
char
*text()
const
= 0;
122
128
virtual
bool
isTextDirty()
const
= 0;
129
134
virtual
void
resetText() = 0;
135
};
136
137
class
EXPORT_SYM
IdButton
:
public
AbstractTextButton
138
{
139
public
:
140
IdButton
(
const
Button::Type::Id
&
id
,
const
char
*defaultText);
141
~
IdButton
();
142
143
virtual
void
setText
(
const
char
*text);
144
virtual
const
char
*
text
()
const
;
145
virtual
bool
isTextDirty
()
const
;
146
virtual
void
setPressed
(
bool
pressed);
147
virtual
bool
value
()
const
;
148
virtual
void
resetText
();
149
150
private
:
151
Button::Type::Id
m_id;
152
char
*m_defaultText;
153
};
154
160
class
EXPORT_SYM
ExtraButtons
161
{
162
public
:
168
static
inline
void
show
() { setShown(
true
); }
169
175
static
inline
void
hide
() { setShown(
false
); }
176
183
static
void
setShown(
const
bool
& shown);
184
190
static
bool
isShown();
191
};
192
197
namespace
Button
198
{
200
extern
EXPORT_SYM
IdButton
A
;
202
extern
EXPORT_SYM
IdButton
B
;
204
extern
EXPORT_SYM
IdButton
C
;
205
207
extern
EXPORT_SYM
IdButton
X
;
209
extern
EXPORT_SYM
IdButton
Y
;
211
extern
EXPORT_SYM
IdButton
Z
;
212
214
extern
EXPORT_SYM
IdButton
Side
;
215
216
// extern AbstractButton side;
217
219
extern
EXPORT_SYM
IdButton
*
const
all
[7];
220
}
221
222
#endif
include
kovan
button.hpp
Generated on Mon Aug 19 2013 00:33:00 for libkovan by
1.8.4